class CreatePostRequest {
  final String userId;
  final String? openimUserId;  // 新增：OpenIM用户ID
  final int circleId;        // 改为int类型
  final String title;
  final String content;
  final List<String>? images;
  final List<String>? videos;
  final List<int>? tagIds;   // 改为List<int>类型
  final String visibility;
  final String status;
  // 新增：位置字段
  final double? locationLatitude;
  final double? locationLongitude;
  final String? locationAddress;

  CreatePostRequest({
    required this.userId,
    this.openimUserId,       // 新增：OpenIM用户ID参数
    required this.circleId,   // int类型
    required this.title,
    required this.content,
    this.images,
    this.videos,
    this.tagIds,             // List<int>?类型
    this.visibility = 'public',
    this.status = 'published',
    // 新增：位置字段
    this.locationLatitude,
    this.locationLongitude,
    this.locationAddress,
    
  });

  Map<String, dynamic> toJson() => {
    'user_id': userId,
    if (openimUserId != null) 'openim_user_id': openimUserId,  // 新增：OpenIM用户ID序列化
    'circle_id': circleId,    // 直接传递int值
    'title': title,
    'content': content,
    if (images != null) 'images': images,
    if (videos != null) 'videos': videos,
    if (tagIds != null) 'tag_ids': tagIds,  // 直接传递int数组
    'visibility': visibility,
    'status': status,
    // 新增：位置字段序列化
    if (locationLatitude != null) 'location_latitude': locationLatitude,
    if (locationLongitude != null) 'location_longitude': locationLongitude,
    if (locationAddress != null) 'location_address': locationAddress,
  };
}